package com.ra.coupon;


import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.espirit.eap.sa.LoginUser;
import com.googlecode.cswish.annotation.cm;
import com.ra.order.rental.RentalOrder;

/**
 * 用户优惠券
 * 
 * @author colin
 * 
 */
@Entity
public class UserCoupon {
	
	/**优惠券状态：过期 */
	@cm("过期")
	public static Integer STATUS_OVERDUE = 0;
	
	/**优惠券状态：可用 */
	@cm("可用")
	public static Integer STATUS_AVAILABLE = 1;
	
	/**优惠券状态：已用 */
	@cm("已用")
	public static Integer STATUS_USED = 2;
	
	private Integer id;

	@cm("领券手机号")
	private String phone;
	
	@cm("券编号")
	private String couponCode;
	
	//状态（0：过期；1：可用；2：已用）
	@cm("状态")
	private Integer status;
	
	@cm("开始时间（有效时间）")
	private Date beginTime;
	
	@cm("结束时间（有效时间）")
	private Date endTime;
	
	@cm("使用时间")
	private Date usedTime;
	
	@cm("所属人")
	private LoginUser user;
	
	@cm("说明")
	private String remark;
	
	@cm("领券时间")
	private Date createTime;
	
	@cm("分享人的电话号码")
	private String sharePhone;
	
	@cm("是否裂变")
	private Boolean fissioned;
	
	@cm("所属券")
	private Coupon coupon;
	
	@cm("订单编号")
	private String orderCode;
	
	@cm("是否查看过标志")
	private Boolean newCoupon;

	//判断是否已经领取
	// @Transient
	private Boolean fetched;
	
	// 对应订单
	private RentalOrder rentalOrder;

	@ManyToOne(fetch=FetchType.LAZY)
	public RentalOrder getRentalOrder() {
		return rentalOrder;
	}

	public void setRentalOrder(RentalOrder rentalOrder) {
		this.rentalOrder = rentalOrder;
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCouponCode() {
		return couponCode;
	}

	public void setCouponCode(String couponCode) {
		this.couponCode = couponCode;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getUsedTime() {
		return usedTime;
	}

	public void setUsedTime(Date usedTime) {
		this.usedTime = usedTime;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	public LoginUser getUser() {
		return user;
	}

	public void setUser(LoginUser user) {
		this.user = user;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getSharePhone() {
		return sharePhone;
	}

	public void setSharePhone(String sharePhone) {
		this.sharePhone = sharePhone;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	public Coupon getCoupon() {
		return coupon;
	}

	public void setCoupon(Coupon coupon) {
		this.coupon = coupon;
	}
	
	public Boolean getFissioned() {
		return fissioned;
	}

	public void setFissioned(Boolean fissioned) {
		this.fissioned = fissioned;
	}
	
	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	@Transient
	public Boolean getFetched() {
		return fetched;
	}

	public void setFetched(Boolean fetched) {
		this.fetched = fetched;
	}
	
	public Boolean getNewCoupon() {
		return newCoupon;
	}

	public void setNewCoupon(Boolean newCoupon) {
		this.newCoupon = newCoupon;
	}
}
